package com.version1.diabeco.ui.reporte;

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.version1.diabeco.ActivityMain;
import com.version1.diabeco.R;
import com.version1.diabeco.model.glucosa.Glucosa;
import com.version1.diabeco.model.peso.Peso;
import com.version1.diabeco.model.comida.Comida;


/**
 * Adapter para visualizacion de registros en ListView con el siguiente formato: 
 * 
 * [Imagen][Glucosa]  [Unidad] 		|
 * 							   		| [Imagen] 
 * [Imagen][Fecha] 	[Imagen][Hora]  |
 * 
 */

public class ReporteAdapterPeso extends ArrayAdapter {
	private final Context context;
	private final List values;
	
	public ReporteAdapterPeso(Context context, int resource, List values) {
		super(context, resource, values);
		this.context = context;
		this.values = values;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.activity_peso_fila, parent, false);
		
		Peso peso = (Peso) values.get(position);
		
		TextView textView = (TextView) rowView.findViewById(R.id.textViewPesoFilaFecha);
		textView.setText(ActivityMain.DATE_FORMAT.format(peso.getFecha()));
		
		textView = (TextView) rowView.findViewById(R.id.textViewPesoFilaHora);
		textView.setText(ActivityMain.TIME_FORMAT.format(peso.getFecha()));
		
		textView = (TextView) rowView.findViewById(R.id.textViewPesoFilaPeso);
		textView.setText(peso.getPeso().toString());
		textView = (TextView) rowView.findViewById(R.id.textViewPesoFilaUnidad);
		textView.setText(peso.getUm());

		return rowView;
	}
}
